Print Documents Event
To handle the Print Documents event, your application should print the
documents specified in the Apple event. The Print Documents event
contains a list of documents to print in its direct parameter. Your application
extracts this information and then prints the specified documents. Your
application should not open any windows for the documents. Also note that your
application should remain open after processing the
Print Documents event; when appropriate, the Finder sends your
application a Quit Application event immediately after sending it a
Print Documents event.
The following program shows a handler for the Print Documents event.
This handler is similar to the handler for the Open Documents event. The code
illustrates how to print the documents referred to in the direct parameter.
// A handler for the Print Documents event
// Assuming inclusion of
#include <AppleEvents.h>
long handlerRefcon);
void DoError (OSErr myErr); long handlerRefcon)
{
long index, itemsInList;
// it into docList
typeAEList, & docList);
if ( myErr)
DoError( myErr);
// check for missing required parameters
myErr = MyGotRequiredParams( theAppleEvent);
if ( myErr) {
// an error occurred: do the necessary error handling
return myErr;
}
// count the number of descriptor records in the list
// now get each descriptor record from the list, coerce
// the returned data to an FSSpec record, and print the // associated file
for ( index=1; index<= itemsInList; index++) {
& returnedType, (Ptr)& myFSS, sizeof( myFSS), & actualSize);
if ( myErr)
DoError( myErr);
myErr = MyPrintFile(& myFSS);
if ( myErr)
DoError( myErr);
}
}
A listing of MyGotRequiredParams may be found under